package cn.chinaunicom.sdsi.gacx.sys.controller;

import cn.chinaunicom.sdsi.gacx.sys.entity.GaSendMessEntity;
import cn.chinaunicom.sdsi.gacx.sys.service.GaSendMessService;

import cn.chinaunicom.sdsi.frm.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONObject;

/**
 * @author lzq
 * 2017-5-15 10:16:37
 *
 */

@Controller
@RequestMapping("gaSendMessController")
public class GaSendMessController extends BaseController{

	private final Log log = LogFactory.getLog(GaSendMessController.class);
	
	@Autowired
	private GaSendMessService gaSendMessService;

	/**
	 * 跳转至查询页面
	 */
	@RequestMapping("/gaSendMessControllerMain")
	public ModelAndView gaSendMessControllerMain(ModelAndView mv){
		log.debug("GaSendMessController.gaSendMessControllerMain{}");
		mv.setViewName("sys/syscontroller/GaSendMessList");
		return mv;
	}
	
	/**
	 * 跳转至新增页面
	 */
	@RequestMapping("/showAddPage")
	public ModelAndView showAddPage(ModelAndView mv){
		mv.setViewName("sys/syscontroller/GaSendMessAdd");
		return mv;
	}
	
	/**
	 * 分页查询
	 * @param start 开始条数,名称不可改变，参数为分页组件传入
	 * @param length 每页大小,名称不可改变，参数为分页组件传入
	 */
	@ResponseBody
	@RequestMapping("/search4PageList")
	public JSONObject search4PageList(GaSendMessEntity gaSendMessEntity,Integer start, Integer length){
		
		log.debug("GaSendMessController.search4PageList{}");
		return gaSendMessService.search4PageList(gaSendMessEntity,start,length);
	}
	
	/**
	 * 查询单条数据
	 */
	@RequestMapping("/selectByPrimaryKey")
	public ModelAndView selectByPrimaryKey(GaSendMessEntity gaSendMessEntity,ModelAndView mv){
		
		log.debug("GaSendMessController.selectByPrimaryKey{}");
		GaSendMessEntity bean=gaSendMessService.selectByPrimaryKey(gaSendMessEntity);
		mv.addObject("bean",bean);
		mv.setViewName("sys/syscontroller/GaSendMessUpdate");
		return mv;
	}
	
	/**
	 * 删除单条数据
	 */
	@ResponseBody
	@RequestMapping("/deleteByPrimaryKey")
	public int deleteByPrimaryKey(GaSendMessEntity gaSendMessEntity){
		int delnum = gaSendMessService.deleteByPrimaryKey(gaSendMessEntity);
		return delnum;
	}

	/**
	 * 保存数据
	 */
	@ResponseBody
	@RequestMapping("/addObject")
	public int addObject(GaSendMessEntity gaSendMessEntity){
		int insertnum = gaSendMessService.addObject(gaSendMessEntity);
		return insertnum;
	}

	/**
	 * 修改单条数据
	 */
	@ResponseBody
	@RequestMapping("/updateByPrimaryKey")
	public int updateByPrimaryKey(GaSendMessEntity gaSendMessEntity){
		int updatetnum = gaSendMessService.updateByPrimaryKey(gaSendMessEntity);
		return updatetnum;
	}
}